package com.xyy.saas.payment.service.impl;

import com.xyy.saas.payment.dao.mapper.PayFinanceApplyMapper;
import com.xyy.saas.payment.dao.model.PayFinanceApply;
import com.xyy.saas.payment.service.PinganLoanFinanceApplyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author huguangming
 * @since 2022/10/12
 */
@Service
@Slf4j
public class PinganLoanFinanceApplyServiceImpl implements PinganLoanFinanceApplyService {

    @Resource
    private PayFinanceApplyMapper payFinanceApplyMapper;

    @Override
    public int insert(PayFinanceApply record) {
        return payFinanceApplyMapper.insertSelective(record);
    }

    @Override
    public PayFinanceApply selectByThirdApplyNo(String thirdApplyNo) {
        return payFinanceApplyMapper.selectByThirdApplyNo(thirdApplyNo);
    }

    @Override
    public PayFinanceApply selectByLoanBalanceNo(String loanBalanceNo) {
        return payFinanceApplyMapper.selectByLoanBalanceNo(loanBalanceNo);
    }

    @Override
    public int updateByPrimaryKeySelective(PayFinanceApply record) {
        if (record.getUpdateTime() == null) {
            record.setUpdateTime(new Date());
        }
        return payFinanceApplyMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public List<PayFinanceApply> selectListByBusinessUserIdAndApplyStatus(String businessUserId, String applyStatus) {
        return payFinanceApplyMapper.selectListByBusinessUserIdAndApplyStatus(businessUserId, applyStatus);
    }

    @Override
    public PayFinanceApply findLatestRecord(String businessUserId, Integer financeChannel) {
        return payFinanceApplyMapper.findLatestRecord(businessUserId, financeChannel);
    }

    @Override
    public PayFinanceApply findLatestRecordByLoanBalanceNo(String loanBalanceNo, Integer financeChannel) {
        return payFinanceApplyMapper.findLatestRecordByLoanBalanceNo(loanBalanceNo, financeChannel);
    }
}
